package com.szd.service.impl;

import com.github.pagehelper.PageHelper;
import com.szd.dao.MemberMapper;
import com.szd.pojo.Member;
import com.szd.service.IMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberServiceimpl implements IMemberService {

    @Autowired
    private MemberMapper memberMapper;
    //根据用户名和密码查询会员
    @Override
    public Member getMemberByNicknameAndPwd(Member member) {
       // Member member = memberMapper.getMemberByNicknameAndPwd(member);
        Member member1 = memberMapper.getMemberByNicknameAndPwd(member);
        return member1;
    }
    //查询所有会员
    @Override
    public List<Member> getAllMembers(String nickname,Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Member> memberList = memberMapper.getAllMembers(nickname);
        return memberList;
    }
    //根据id查询会员
    @Override
    public Member getMemberById(Integer id) {
        Member memberById = memberMapper.getMemberById(id);
        return memberById;
    }
    //添加会员
    @Override
    public int addMember(Member member) {
        int i = memberMapper.addMember(member);
        return i;
    }
    //删除会员
    @Override
    public int deleteMember(Integer id) {
        int i = memberMapper.deleteMember(id);
        return i;
    }
    //修改会员
    @Override
    public int editMember(Member member) {
        int i = memberMapper.editMember(member);
        return i;
    }
    //批量删除
    @Override
    public int deleteAllMember(List<String> ids) {
        int i = memberMapper.deleteAllMember(ids);
        return i;
    }
    //根据用户名查询
    @Override
    public Member getMemberByNickname(String nickname) {
        Member member = memberMapper.getMemberByNickname(nickname);
        return member;
    }
    //详情
    @Override
    public Member detailMember(Integer id) {
        Member member = memberMapper.detailMember(id);
        return member;
    }
}
